<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta property="og:type" content="website">
<meta property="og:title" content="西瓜古古🍉">
<meta property="og:url" content="http://yoursite.com/page/2/index.html">
<meta property="og:site_name" content="西瓜古古🍉">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="西瓜古古🍉">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 0,
      author: '博主'
    }
  };
</script>

  <title> 西瓜古古🍉 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left 
   page-home 
 ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">西瓜古古🍉</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle"></p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/21/js中数组和字符串的常用方法总结/" itemprop="url">
                  js中数组和字符串的常用方法总结
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-21T11:48:46+08:00" content="2017-09-21">
              2017-09-21
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="数组"><a href="#数组" class="headerlink" title="数组"></a>数组</h2><h3 id="不改变原数组"><a href="#不改变原数组" class="headerlink" title="不改变原数组"></a>不改变原数组</h3><ul>
<li>slice（）<ul>
<li>用途： Array.prototype.slice.call(arguments)能将<font color="red">具有length属性</font>的对象转成数组,<br>此对象可以包括arguments伪数组、数组、{length:2,”0”:”haha”,”1”:’oye’}<br>-》 借用call将非数组转换成数组的方法<font color="red"><br>方法一：var args = Array.prototype.slice.call(arguments);<br>方法二：var args = [].slice.call(arguments, 0);<br></font>

</li>
</ul>
</li>
</ul>
<pre><code>var a={length:2,0:&apos;first&apos;,1:&apos;second&apos;};//伪数组,有length属性
console.log(Array.prototype.slice.call(a,0));// [&quot;first&quot;, &quot;second&quot;],调用数组的slice(0);

var a={length:2,0:&apos;first&apos;,1:&apos;second&apos;};
console.log(Array.prototype.slice.call(a,1));//[&quot;second&quot;]，调用数组的slice(1);

var a={0:&apos;first&apos;,1:&apos;second&apos;};//去掉length属性，返回一个空数组
console.log(Array.prototype.slice.call(a,0));//[]

function test(){
  console.log(Array.prototype.slice.call(arguments,0));//[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]，slice(0)
  console.log(Array.prototype.slice.call(arguments,1));//[&quot;b&quot;, &quot;c&quot;],slice(1)
}
test(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;);
</code></pre>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/21/HTML中有用的字符实体/" itemprop="url">
                  HTML常用的字符实体
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-21T11:40:55+08:00" content="2017-09-21">
              2017-09-21
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="常用实体名称"><a href="#常用实体名称" class="headerlink" title="常用实体名称"></a>常用实体名称</h2><table>
<thead>
<tr>
<th>显示结果</th>
<th style="text-align:center">描述</th>
<th style="text-align:right">实体名称</th>
</tr>
</thead>
<tbody>
<tr>
<td>&gt;</td>
<td style="text-align:center">大于号</td>
<td style="text-align:right"><code>&amp;gt;</code></td>
</tr>
</tbody>
</table>
<table class=""><br><thead style="backgroundColor:gray"><br><tr><br>    <td>显示结果</td><br>    <td>描述</td><br>    <td>实体名称</td><br></tr><br></thead><br><tbody><br><tr><br>    <td> &gt; </td><br>    <td>大于号</td><br>    <td><code>&amp;gt;</code></td><br></tr><br><tr><br>    <td> &lt; </td><br>    <td>小于号</td><br>    <td><code>&amp;lt;</code></td><br></tr><br><tr><br>    <td>   </td><br>    <td>空格</td><br>    <td><code>&amp;nbsp;</code></td><br></tr><br><tr><br>    <td> x </td><br>    <td>乘号</td><br>    <td><code>&amp;times;</code></td><br></tr><br><tr><br>    <td> © </td><br>    <td>版权（copyright</td><br>    <td><code>&amp;copy;</code></td><br></tr><br><tr><br>    <td> ¥ </td><br>    <td>元(yen)</td><br>    <td><code>&amp;yen;</code></td><br></tr><br><tr><br>    <td> &amp; </td><br>    <td>和号</td><br>    <td><code>&amp;amp;</code></td><br></tr><br><tr><br>    <td> “ </td><br>    <td>引号</td><br>    <td><code>&amp;quot;</code></td><br></tr><br><tr><br>    <td> ‘ </td><br>    <td>撇号</td><br>    <td><code>&amp;apos; (IE不支持)</code></td><br></tr><br></tbody><br></table>





          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/21/前端学习相关网站/" itemprop="url">
                  前端学习相关网站
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-21T11:34:45+08:00" content="2017-09-21">
              2017-09-21
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="百度静态资源公共库"><a href="#百度静态资源公共库" class="headerlink" title="百度静态资源公共库"></a>百度静态资源公共库</h2><p><a href="cdn.code.baidu.com">百度静态资源公共库</a></p>
<h2 id="AngularJs"><a href="#AngularJs" class="headerlink" title="AngularJs"></a>AngularJs</h2><p>[1] <a href="http://www.cnblogs.com/powertoolsteam/p/angularjs-introdection.html" target="_blank" rel="external">http://www.cnblogs.com/powertoolsteam/p/angularjs-introdection.html</a><br>[2] <a href="http://www.apjs.net/" target="_blank" rel="external">http://www.apjs.net/</a><br>[3] <a href="http://www.angularjs.cn/" target="_blank" rel="external">http://www.angularjs.cn/</a><br>[4] <a href="http://docs.angularjs.cn/api" target="_blank" rel="external">http://docs.angularjs.cn/api</a><br>[5] <a href="https://material.angularjs.org" target="_blank" rel="external">https://material.angularjs.org</a><br>[6] <a href="http://angular-ui.github.io/" target="_blank" rel="external">http://angular-ui.github.io/</a></p>
<h2 id="markdown相关文档"><a href="#markdown相关文档" class="headerlink" title="markdown相关文档"></a>markdown相关文档</h2><p>[1] <a href="http://blog.csdn.net/u011419965/article/details/50536937" target="_blank" rel="external">http://blog.csdn.net/u011419965/article/details/50536937</a></p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/21/js中call和bind的使用/" itemprop="url">
                  js中call和bind的使用
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-21T11:24:22+08:00" content="2017-09-21">
              2017-09-21
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="call-和-bind"><a href="#call-和-bind" class="headerlink" title="call 和 bind"></a>call 和 bind</h2><p>## </p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/19/AMD和CMD规范/" itemprop="url">
                  未命名
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-19T16:54:24+08:00" content="2017-09-19">
              2017-09-19
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>title: AMD和CMD规范<br>tags: </p>
<h2 id="categories"><a href="#categories" class="headerlink" title="categories: "></a>categories: </h2><h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p>[require.js的用法] <a href="http://www.ruanyifeng.com/blog/2012/11/require_js.html" target="_blank" rel="external">http://www.ruanyifeng.com/blog/2012/11/require_js.html</a></p>
<h2 id="Sea-js-和-Require-js"><a href="#Sea-js-和-Require-js" class="headerlink" title="Sea.js 和 Require.js"></a>Sea.js 和 Require.js</h2><p>// CMD 对于依赖的模块,CMD 是延迟执行<br>define(function(require, exports, module) {<br>    var a = require(‘./a’)<br>    a.doSomething()<br>    // …<br>    var b = require(‘./b’) // 依赖可以就近书写<br>    b.doSomething()<br>    // …<br>})</p>
<p>// AMD 对于依赖的模块,AMD 是提前执行<br>define([‘./a’, ‘./b’], function(a, b) { // 依赖必须一开始就写好<br>    a.doSomething()<br>    // …<br>    b.doSomething()<br>    // …<br>})</p>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/18/jQuery-cookie/" itemprop="url">
                  jQuery插件--cookie使用
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-18T17:45:06+08:00" content="2017-09-18">
              2017-09-18
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/jQuery插件/" itemprop="url" rel="index">
                    <span itemprop="name">jQuery插件</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="赋值操作"><a href="#赋值操作" class="headerlink" title="赋值操作"></a>赋值操作</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">$.cookie(&quot;the_cookie&quot;,&quot;the_value&quot;,&#123;</div><div class="line">    expiers: 7,</div><div class="line">    path: &quot;/&quot; ,</div><div class="line">    domain: &quot;jQuery.com&quot;,</div><div class="line">    secure: ture  </div><div class="line">&#125;)</div></pre></td></tr></table></figure>
<h2 id="注意事项"><a href="#注意事项" class="headerlink" title="注意事项"></a>注意事项</h2><p>the_value 必须是字符串</p>
<p>$(“the_key”)取到的值也是字符串</p>
<ul>
<li>字符串转json—–JSON.parse()</li>
<li>json转字符串—–JSON.stringify()</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/18/Ajax错误解决方法/" itemprop="url">
                  Ajax错误解决方法
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-18T08:43:25+08:00" content="2017-09-18">
              2017-09-18
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/Ajax/" itemprop="url" rel="index">
                    <span itemprop="name">Ajax</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="jQuery中Ajax运行bug及其解决方案"><a href="#jQuery中Ajax运行bug及其解决方案" class="headerlink" title="jQuery中Ajax运行bug及其解决方案"></a>jQuery中Ajax运行bug及其解决方案</h2><ul>
<li>form标签中表单元素无name属性，或者name属性名和后端接口文档要求不一致</li>
<li>url和后端接口文档要求不一致</li>
<li>data数据传参和后端接口文档要求不一致</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/17/正则表达式/" itemprop="url">
                  正则表达式
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-17T09:22:52+08:00" content="2017-09-17">
              2017-09-17
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>^            匹配输入字符串的开始位置。<br>\d            匹配一个数字字符。等价于 [0-9]。</p>
<ul>
<li>匹配前面的子表达式零次或多次。<br>\            将下一个字符标记为一个特殊字符、或一个原义字符、或一个 向后引用、或一个八进制转义符。<br>[^a-z]        负值字符范围。匹配任何不在指定范围内的任意字符。<br>[^xyz]        负值字符集合。匹配未包含的任意字符。<br>\w            匹配包括下划线的任何单词字符。等价于’[A-Za-z0-9_]’。<br>{n}            n 是一个非负整数。匹配确定的 n 次。<br>$            匹配输入字符串的结束位置。</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/16/mac指令/" itemprop="url">
                  Mac电脑指令
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-16T23:18:13+08:00" content="2017-09-16">
              2017-09-16
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/指令/" itemprop="url" rel="index">
                    <span itemprop="name">指令</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="Mac电脑显示隐藏文件"><a href="#Mac电脑显示隐藏文件" class="headerlink" title="Mac电脑显示隐藏文件"></a>Mac电脑显示隐藏文件</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">defaults write com.apple.finder AppleShowAllFiles Yes &amp;&amp; killall Finder //显示隐藏文件</div><div class="line">defaults write com.apple.finder AppleShowAllFiles No &amp;&amp; killall Finder //不显示隐藏文件</div></pre></td></tr></table></figure>
          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
      

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                
                <a class="post-title-link" href="/2017/09/15/git/" itemprop="url">
                  git和github进行代码管理(Mac电脑)
                </a>
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2017-09-15T23:52:37+08:00" content="2017-09-15">
              2017-09-15
            </time>
          </span>

          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <h2 id="代码管理的区域（自用github和码云作为远程仓库）"><a href="#代码管理的区域（自用github和码云作为远程仓库）" class="headerlink" title="代码管理的区域（自用github和码云作为远程仓库）"></a>代码管理的区域（自用github和码云作为远程仓库）</h2><p>Wrokspace： 工作目录/工作区（本地创建的，用于存放代码的文件夹）<br>Stage：暂存区（.git文件夹）<br>Repository： 本地仓库<br>Remote： 远程仓库（github或码云）</p>
<blockquote>
<p>git流程图</p>
</blockquote>
<p><img src="../img/git流程图.png"></p>
<h2 id="git是什么？"><a href="#git是什么？" class="headerlink" title="git是什么？"></a>git是什么？</h2><p>git是一种版本控制工具</p>
<h2 id="github是什么？"><a href="#github是什么？" class="headerlink" title="github是什么？"></a>github是什么？</h2><p>github相当于是代码管理的远程仓库</p>
<h2 id="版本控制工具"><a href="#版本控制工具" class="headerlink" title="版本控制工具"></a>版本控制工具</h2><ol>
<li>管理源代码（方便团队成员相互协作开发）</li>
<li>代码的合并：保存所有的历史记录</li>
</ol>
<h2 id="git和github的使用"><a href="#git和github的使用" class="headerlink" title="git和github的使用"></a>git和github的使用</h2><h3 id="本地操作"><a href="#本地操作" class="headerlink" title="本地操作"></a>本地操作</h3><h4 id="一、基本操作"><a href="#一、基本操作" class="headerlink" title="一、基本操作"></a>一、基本操作</h4><ol>
<li>配置用户信息<br> git config –global user.name github用户名<br> git config –global user.email github邮箱</li>
<li>新建一个Git代码库/初始化本地仓库<br> git init<br> -&gt; 此时会在工作目录生成.git 文件，但是Mac电脑默认是隐藏的</li>
<li>查看仓库中所有文件的文件状态<br> git status</li>
<li>把工作目录中的文件添加到暂存区<br> git add *<br> -&gt; 将工作目录中的所有文件都添加到暂存区<br> git add 文件列表<br> -&gt; 添加制定文件到暂存区<br> -&gt; git rm –cached 文件名称 #add的逆操作</li>
<li>把暂存区的文件添加到本地仓库<br> git commit -m ‘备注信息’<br> git commit -a -m 备注信息  #(-a只能提交已修改的文件，不能提交未跟踪文件）<br> -&gt; git log 可以查看commit的日志,查看提交历史<br>-&gt; 至此，本地的文件的基本管理已经结束<h4 id="二、分支"><a href="#二、分支" class="headerlink" title="二、分支"></a>二、分支</h4>git branch              #查看本地所有分支<br>git branch -a           #查看所有的分支,包括远程分支<br>git branch -r           #查看远程所有分支<br>git branch 分支名称  #创建分支<br> -&gt; git checkout -b 分支名称 #也可用于创建分支<br>git checkout 分支名称    #切换到指定分支<br>git merge 分支名称       #合并指定分支到当前分支<br>git branch -d 分支名称   #删除分支,如果没有被合并,无法删除<br>git branch -D           #强行删除分支，请慎重<br>git push origin 分支名称 #推送本地分支至远程仓库，创建远程分支<br>git push origin –delete 分支名称 #删除远程分支<h4 id="三、撤销-回滚"><a href="#三、撤销-回滚" class="headerlink" title="三、撤销(回滚)"></a>三、撤销(回滚)</h4>git checkout 文件列表  #回滚修改的内容v<br>git checkout .        #(回滚所有的修改，慎重使用)</li>
</ol>
<ul>
<li>使用本地仓库的快照进行回滚<ul>
<li>git reset<ul>
<li>–hard</li>
<li>–soft</li>
<li>–mixed (默认参数)<br>git reset –hard HEAD^  #回滚最后一次提交<br>git reset –hard HEAD   #回滚所有的工作目录和暂存区内容</li>
</ul>
</li>
</ul>
</li>
</ul>
<h4 id="四、删除"><a href="#四、删除" class="headerlink" title="四、删除"></a>四、删除</h4><h3 id="远程仓库的相关操作"><a href="#远程仓库的相关操作" class="headerlink" title="远程仓库的相关操作"></a>远程仓库的相关操作</h3><ul>
<li>克隆远程仓库的项目<ul>
<li>git clone 远程仓库地址 项目名称</li>
</ul>
</li>
<li>拉取远程的分支<ul>
<li>git pull 远程仓库地址 远程分支名称:本地分支名称</li>
</ul>
</li>
<li>推送分支到远程仓库<ul>
<li>git push 远程仓库地址 本地分支名称:远程分支名称</li>
</ul>
</li>
<li>添加远程仓库别名<ul>
<li>git remote add 别名 远程仓库地址</li>
</ul>
</li>
<li>删除远程仓库别名<ul>
<li>git remote remove 别名</li>
</ul>
</li>
<li>查看远程仓库别名的详细信息<ul>
<li>git remote show 别名</li>
</ul>
</li>
<li>查看所有别名<ul>
<li>git remote</li>
</ul>
</li>
</ul>

          
        
      
    </div>

    <div>
      
    </div>

    <div>
      
    </div>

    <footer class="post-footer">
      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="page-number" href="/page/4/">4</a><a class="extend next" rel="next" href="/page/3/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      

      <section class="site-overview sidebar-panel  sidebar-panel-active ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/23103K3MK.jpg"
               alt="beikexixi" />
          <p class="site-author-name" itemprop="name">beikexixi</p>
          <p class="site-description motion-element" itemprop="description"></p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">35</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">9</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">10</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com" target="_blank" title="Github">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  Github
                </a>
              </span>
            
          
        </div>

        
        

        
        

      </section>

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">beikexixi</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="http://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  

  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  



  
  
  

  

  

</body>
</html>
